
import axios from 'axios';
import qs from 'qs';
Vue.prototype.$qs = qs;
import ServerConfig from '../../public/serverConfig.json';
import Vue from 'vue';



export const  getQiniuToken = (type) =>{

    return new Promise((resolve, reject) => {
        if(type == "wlming"){
            var scope = ServerConfig.scope_img
        }else{
            var scope = ServerConfig.scope_video
        }
        const data = { scope: scope};
        axios({
            url: "/admin/login/qiniutoken",
            method: "post",
            headers:{
                Authorization: "Bearer " + localStorage.getItem("uid")+"."+localStorage.getItem("token"),
                'Content-type': 'application/x-www-form-urlencoded'
            },
            data: qs.stringify(data)
        }).then(res => {
            if(res.data.code != 10000){
                return false;
            }else{
                resolve(res.data.data)
            }
        });
    })


}

// import { getQiniuToken } from '@/server/token'
// async   getData() {
//     // await getQiniuToken().then(res=>{
//     //     console.log(res);
//     // })
//
//     let token = await getQiniuToken()

//console.log(token)

